package com.xn.app.muying.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.util.APIMethod;
import com.xn.app.muying.util.BaseActivity;
import com.xn.app.muying.util.HttpUtil;
import com.zhuge.analysis.stat.ZhugeSDK;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2016/10/16.
 */
public class KePuDetailActivity extends BaseActivity implements HttpUtil.OnGetDataListener {

    private TextView tv;
    private ImageView iv;
    private Handler handler = new Handler();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_kepudetail);
        tv = (TextView) findViewById(R.id.activity_kepudetail_tv);
        iv = (ImageView) findViewById(R.id.activity_kepudetail_iv);
        Intent intent = getIntent();
        String id = intent.getStringExtra("id");
        HttpUtil.getData(APIMethod.Home_KePu3(id),handler,this);

    }

    @Override
    public void onJsonData(String data) {
        try {
            JSONObject object = new JSONObject(data);
            String content = object.optString("content");
            String pictureUrl = object.optString("pictureUrl");
            tv.setText(content);
            iv.setTag(pictureUrl);
            HttpUtil.getBitMap(pictureUrl,handler,iv);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}
